﻿Public Class CEnglishMemo
    Public Sub 添加记录(ByVal MemoId As Integer, ByVal EnglishId As String)
        If MemoId > 0 Then
            If Not 判断是否存在记录(MemoId, EnglishId) Then
                Dim sql As String = "insert into EnglishMEMO(MemoID,EnglishWord,OpTime) values(" & MemoId & ",'" _
                & EnglishId & "',?)"
                Dim cmd As New ADODB.Command
                cmd.CommandText = sql
                Dim pa As ADODB.Parameter = cmd.CreateParameter(, ADODB.DataTypeEnum.adDBTimeStamp, ADODB.ParameterDirectionEnum.adParamInput)
                pa.Value = Now
                cmd.Parameters.Append(pa)
                ct.ExcCommand(cmd)
            End If
        End If
    End Sub

    Public Sub 删除记录(ByVal EnglishId As String)
        Dim sql As String = "delete from EnglishMEMO where EnglishWord='" & EnglishId & "'"
        ct.ExecuteSql(sql)
    End Sub

    Private Function 判断是否存在记录(ByVal MemoId As Integer, ByVal EnglishId As String) As Boolean
        判断是否存在记录 = False
        Dim sql As String = "select * from EnglishMEMO where MemoID=" & MemoId & " and  EnglishWord='" & EnglishId + "'"
        Dim rs As ADODB.Recordset = ct.ExecuteSql(sql)
        If rs IsNot Nothing AndAlso rs.EOF = False Then
            判断是否存在记录 = True
            rs.Close()
        End If
        System.Runtime.InteropServices.Marshal.ReleaseComObject(rs)
    End Function

    Private _ct As Wys.Db.Vb.CTable
    Public Sub New(ByVal ct As Wys.Db.Vb.CTable)
        _ct = ct
    End Sub
End Class
